package com.tz.farmer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.mapper.DataOfShareMapper;
import com.tz.farmer.model.DataOfShare;
import com.tz.farmer.service.DataOfShareService;
import com.tz.farmer.so.DataOfShareSo;
import com.tz.farmer.util.BeanConvertUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class DataOfShareServiceimpl extends ServiceImpl<DataOfShareMapper, DataOfShare> implements DataOfShareService {


    @Override
    public Map getDataOfShare() {
        Map map = new HashMap<>();
        DataOfShare shichangjianguanju = this.getOne(new QueryWrapper<DataOfShare>().eq("property", 11));
        DataOfShare ganghangyuyeju = this.getOne(new QueryWrapper<DataOfShare>().eq("property", 22));
        DataOfShare nongyeju = this.getOne(new QueryWrapper<DataOfShare>().eq("property", 33));
        map.put("shichangjianguanju",shichangjianguanju);
        map.put("ganghangyuyeju",ganghangyuyeju);
        map.put("nongyeju",nongyeju);
        return map;
    }

    @Override
    public ResultEx updateDataOfShare(DataOfShareSo so) {
        DataOfShare dataOfShare = BeanConvertUtils.copyProperties(so, DataOfShare.class);
        boolean b = this.updateById(dataOfShare);
        return b == true ? ResultEx.builder().makeSuccessResult():ResultEx.builder().makeFailedResult();
    }
}
